
_memtest：     文件格式 elf32-i386


Disassembly of section .text:

00000000 <main>:
#include "user.h"


int
main(int argc, char *argv[])
{
   0:	8d 4c 24 04          	lea    0x4(%esp),%ecx
   4:	83 e4 f0             	and    $0xfffffff0,%esp
   7:	ff 71 fc             	push   -0x4(%ecx)
   a:	55                   	push   %ebp
   b:	89 e5                	mov    %esp,%ebp
   d:	51                   	push   %ecx
   e:	83 ec 24             	sub    $0x24,%esp
          
    char * cur_break = (void *)0;
  11:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
    char * old_break = (void *)0;
  18:	c7 45 ec 00 00 00 00 	movl   $0x0,-0x14(%ebp)
    int pre, post;

    printf(1,"number of free frames: %d \n",get_free_frame_cnt());
  1f:	e8 7c 05 00 00       	call   5a0 <get_free_frame_cnt>
  24:	83 ec 04             	sub    $0x4,%esp
  27:	50                   	push   %eax
  28:	68 34 0a 00 00       	push   $0xa34
  2d:	6a 01                	push   $0x1
  2f:	e8 48 06 00 00       	call   67c <printf>
  34:	83 c4 10             	add    $0x10,%esp

      
    printf(1,"Test 1 (sbrk without allocating memory): ");
  37:	83 ec 08             	sub    $0x8,%esp
  3a:	68 50 0a 00 00       	push   $0xa50
  3f:	6a 01                	push   $0x1
  41:	e8 36 06 00 00       	call   67c <printf>
  46:	83 c4 10             	add    $0x10,%esp
    old_break=sbrk(0);
  49:	83 ec 0c             	sub    $0xc,%esp
  4c:	6a 00                	push   $0x0
  4e:	e8 2d 05 00 00       	call   580 <sbrk>
  53:	83 c4 10             	add    $0x10,%esp
  56:	89 45 ec             	mov    %eax,-0x14(%ebp)
    pre=get_free_frame_cnt();
  59:	e8 42 05 00 00       	call   5a0 <get_free_frame_cnt>
  5e:	89 45 e8             	mov    %eax,-0x18(%ebp)
    sbrk(4096*4);//four pages
  61:	83 ec 0c             	sub    $0xc,%esp
  64:	68 00 40 00 00       	push   $0x4000
  69:	e8 12 05 00 00       	call   580 <sbrk>
  6e:	83 c4 10             	add    $0x10,%esp
    cur_break=sbrk(0);
  71:	83 ec 0c             	sub    $0xc,%esp
  74:	6a 00                	push   $0x0
  76:	e8 05 05 00 00       	call   580 <sbrk>
  7b:	83 c4 10             	add    $0x10,%esp
  7e:	89 45 f4             	mov    %eax,-0xc(%ebp)
    post=get_free_frame_cnt();
  81:	e8 1a 05 00 00       	call   5a0 <get_free_frame_cnt>
  86:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    if(cur_break-old_break<4096*4){
  89:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8c:	2b 45 ec             	sub    -0x14(%ebp),%eax
  8f:	3d ff 3f 00 00       	cmp    $0x3fff,%eax
  94:	7f 1b                	jg     b1 <main+0xb1>
        printf(1," fail1! %d \n",cur_break-old_break);
  96:	8b 45 f4             	mov    -0xc(%ebp),%eax
  99:	2b 45 ec             	sub    -0x14(%ebp),%eax
  9c:	83 ec 04             	sub    $0x4,%esp
  9f:	50                   	push   %eax
  a0:	68 7a 0a 00 00       	push   $0xa7a
  a5:	6a 01                	push   $0x1
  a7:	e8 d0 05 00 00       	call   67c <printf>
  ac:	83 c4 10             	add    $0x10,%esp
  af:	eb 2e                	jmp    df <main+0xdf>
    }else if(post<pre){
  b1:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  b4:	3b 45 e8             	cmp    -0x18(%ebp),%eax
  b7:	7d 14                	jge    cd <main+0xcd>
        printf(1," fail2!\n");
  b9:	83 ec 08             	sub    $0x8,%esp
  bc:	68 87 0a 00 00       	push   $0xa87
  c1:	6a 01                	push   $0x1
  c3:	e8 b4 05 00 00       	call   67c <printf>
  c8:	83 c4 10             	add    $0x10,%esp
  cb:	eb 12                	jmp    df <main+0xdf>
    }else{
        printf(1," success!\n");
  cd:	83 ec 08             	sub    $0x8,%esp
  d0:	68 90 0a 00 00       	push   $0xa90
  d5:	6a 01                	push   $0x1
  d7:	e8 a0 05 00 00       	call   67c <printf>
  dc:	83 c4 10             	add    $0x10,%esp
    }

    printf(1,"Test 2 (write to heap mem): ");
  df:	83 ec 08             	sub    $0x8,%esp
  e2:	68 9b 0a 00 00       	push   $0xa9b
  e7:	6a 01                	push   $0x1
  e9:	e8 8e 05 00 00       	call   67c <printf>
  ee:	83 c4 10             	add    $0x10,%esp
    *(cur_break-1)='c';
  f1:	8b 45 f4             	mov    -0xc(%ebp),%eax
  f4:	83 e8 01             	sub    $0x1,%eax
  f7:	c6 00 63             	movb   $0x63,(%eax)
    post=get_free_frame_cnt();
  fa:	e8 a1 04 00 00       	call   5a0 <get_free_frame_cnt>
  ff:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    if(pre>post+2){//allocate at most two frames
 102:	8b 45 e4             	mov    -0x1c(%ebp),%eax
 105:	83 c0 02             	add    $0x2,%eax
 108:	39 45 e8             	cmp    %eax,-0x18(%ebp)
 10b:	7e 14                	jle    121 <main+0x121>
        printf(1," fail!\n");
 10d:	83 ec 08             	sub    $0x8,%esp
 110:	68 b8 0a 00 00       	push   $0xab8
 115:	6a 01                	push   $0x1
 117:	e8 60 05 00 00       	call   67c <printf>
 11c:	83 c4 10             	add    $0x10,%esp
 11f:	eb 12                	jmp    133 <main+0x133>
    }else{
        printf(1," success!\n");
 121:	83 ec 08             	sub    $0x8,%esp
 124:	68 90 0a 00 00       	push   $0xa90
 129:	6a 01                	push   $0x1
 12b:	e8 4c 05 00 00       	call   67c <printf>
 130:	83 c4 10             	add    $0x10,%esp
    }

    printf(1,"Test 3 (deallocating memory): ");
 133:	83 ec 08             	sub    $0x8,%esp
 136:	68 c0 0a 00 00       	push   $0xac0
 13b:	6a 01                	push   $0x1
 13d:	e8 3a 05 00 00       	call   67c <printf>
 142:	83 c4 10             	add    $0x10,%esp
    sbrk(-4*1024);
 145:	83 ec 0c             	sub    $0xc,%esp
 148:	68 00 f0 ff ff       	push   $0xfffff000
 14d:	e8 2e 04 00 00       	call   580 <sbrk>
 152:	83 c4 10             	add    $0x10,%esp
    cur_break=sbrk(0);
 155:	83 ec 0c             	sub    $0xc,%esp
 158:	6a 00                	push   $0x0
 15a:	e8 21 04 00 00       	call   580 <sbrk>
 15f:	83 c4 10             	add    $0x10,%esp
 162:	89 45 f4             	mov    %eax,-0xc(%ebp)
    post=get_free_frame_cnt();
 165:	e8 36 04 00 00       	call   5a0 <get_free_frame_cnt>
 16a:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    if(pre-post>1){
 16d:	8b 45 e8             	mov    -0x18(%ebp),%eax
 170:	2b 45 e4             	sub    -0x1c(%ebp),%eax
 173:	83 f8 01             	cmp    $0x1,%eax
 176:	7e 14                	jle    18c <main+0x18c>
        printf(1," fail!\n");
 178:	83 ec 08             	sub    $0x8,%esp
 17b:	68 b8 0a 00 00       	push   $0xab8
 180:	6a 01                	push   $0x1
 182:	e8 f5 04 00 00       	call   67c <printf>
 187:	83 c4 10             	add    $0x10,%esp
 18a:	eb 12                	jmp    19e <main+0x19e>
    }else{
        printf(1," success!\n");
 18c:	83 ec 08             	sub    $0x8,%esp
 18f:	68 90 0a 00 00       	push   $0xa90
 194:	6a 01                	push   $0x1
 196:	e8 e1 04 00 00       	call   67c <printf>
 19b:	83 c4 10             	add    $0x10,%esp
    }

    printf(1,"Test 4 (allocating too much mem): ");
 19e:	83 ec 08             	sub    $0x8,%esp
 1a1:	68 e0 0a 00 00       	push   $0xae0
 1a6:	6a 01                	push   $0x1
 1a8:	e8 cf 04 00 00       	call   67c <printf>
 1ad:	83 c4 10             	add    $0x10,%esp
    old_break=sbrk(0);
 1b0:	83 ec 0c             	sub    $0xc,%esp
 1b3:	6a 00                	push   $0x0
 1b5:	e8 c6 03 00 00       	call   580 <sbrk>
 1ba:	83 c4 10             	add    $0x10,%esp
 1bd:	89 45 ec             	mov    %eax,-0x14(%ebp)
    sbrk(0x7FFFFFFF);
 1c0:	83 ec 0c             	sub    $0xc,%esp
 1c3:	68 ff ff ff 7f       	push   $0x7fffffff
 1c8:	e8 b3 03 00 00       	call   580 <sbrk>
 1cd:	83 c4 10             	add    $0x10,%esp
    cur_break=sbrk(0);
 1d0:	83 ec 0c             	sub    $0xc,%esp
 1d3:	6a 00                	push   $0x0
 1d5:	e8 a6 03 00 00       	call   580 <sbrk>
 1da:	83 c4 10             	add    $0x10,%esp
 1dd:	89 45 f4             	mov    %eax,-0xc(%ebp)
    if(cur_break!=old_break){
 1e0:	8b 45 f4             	mov    -0xc(%ebp),%eax
 1e3:	3b 45 ec             	cmp    -0x14(%ebp),%eax
 1e6:	74 14                	je     1fc <main+0x1fc>
        printf(1," fail!\n");
 1e8:	83 ec 08             	sub    $0x8,%esp
 1eb:	68 b8 0a 00 00       	push   $0xab8
 1f0:	6a 01                	push   $0x1
 1f2:	e8 85 04 00 00       	call   67c <printf>
 1f7:	83 c4 10             	add    $0x10,%esp
 1fa:	eb 12                	jmp    20e <main+0x20e>
    }else{
        printf(1," success!\n");
 1fc:	83 ec 08             	sub    $0x8,%esp
 1ff:	68 90 0a 00 00       	push   $0xa90
 204:	6a 01                	push   $0x1
 206:	e8 71 04 00 00       	call   67c <printf>
 20b:	83 c4 10             	add    $0x10,%esp
    }

    printf(1,"Test 5 (access invalid mem, two page faults): \n" );
 20e:	83 ec 08             	sub    $0x8,%esp
 211:	68 04 0b 00 00       	push   $0xb04
 216:	6a 01                	push   $0x1
 218:	e8 5f 04 00 00       	call   67c <printf>
 21d:	83 c4 10             	add    $0x10,%esp
    if(fork()==0){
 220:	e8 cb 02 00 00       	call   4f0 <fork>
 225:	85 c0                	test   %eax,%eax
 227:	75 22                	jne    24b <main+0x24b>
        *(cur_break+4096)='c';
 229:	8b 45 f4             	mov    -0xc(%ebp),%eax
 22c:	05 00 10 00 00       	add    $0x1000,%eax
 231:	c6 00 63             	movb   $0x63,(%eax)
        printf(1," test failure 1!\n");
 234:	83 ec 08             	sub    $0x8,%esp
 237:	68 34 0b 00 00       	push   $0xb34
 23c:	6a 01                	push   $0x1
 23e:	e8 39 04 00 00       	call   67c <printf>
 243:	83 c4 10             	add    $0x10,%esp
        exit();
 246:	e8 ad 02 00 00       	call   4f8 <exit>
    }else{
        wait();
 24b:	e8 b0 02 00 00       	call   500 <wait>
    }    
    if(fork()==0){
 250:	e8 9b 02 00 00       	call   4f0 <fork>
 255:	85 c0                	test   %eax,%eax
 257:	75 3e                	jne    297 <main+0x297>
        int i=0;        
 259:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
        while(cur_break){
 260:	eb 18                	jmp    27a <main+0x27a>
            cur_break--;
 262:	83 6d f4 01          	subl   $0x1,-0xc(%ebp)
            if(*(cur_break)==0){
 266:	8b 45 f4             	mov    -0xc(%ebp),%eax
 269:	0f b6 00             	movzbl (%eax),%eax
 26c:	84 c0                	test   %al,%al
 26e:	75 06                	jne    276 <main+0x276>
            //read memory at cur_break
                // should cause page fault below stack
                i++;
 270:	83 45 f0 01          	addl   $0x1,-0x10(%ebp)
 274:	eb 04                	jmp    27a <main+0x27a>
            }else{
                i++;
 276:	83 45 f0 01          	addl   $0x1,-0x10(%ebp)
        while(cur_break){
 27a:	83 7d f4 00          	cmpl   $0x0,-0xc(%ebp)
 27e:	75 e2                	jne    262 <main+0x262>
            }
        }
        printf(1,"test failure 2!\n");
 280:	83 ec 08             	sub    $0x8,%esp
 283:	68 46 0b 00 00       	push   $0xb46
 288:	6a 01                	push   $0x1
 28a:	e8 ed 03 00 00       	call   67c <printf>
 28f:	83 c4 10             	add    $0x10,%esp
        exit();
 292:	e8 61 02 00 00       	call   4f8 <exit>
    }else{
        wait();
 297:	e8 64 02 00 00       	call   500 <wait>
    }
    exit();
 29c:	e8 57 02 00 00       	call   4f8 <exit>

000002a1 <stosb>:
               "cc");
}

static inline void
stosb(void *addr, int data, int cnt)
{
 2a1:	55                   	push   %ebp
 2a2:	89 e5                	mov    %esp,%ebp
 2a4:	57                   	push   %edi
 2a5:	53                   	push   %ebx
  asm volatile("cld; rep stosb" :
 2a6:	8b 4d 08             	mov    0x8(%ebp),%ecx
 2a9:	8b 55 10             	mov    0x10(%ebp),%edx
 2ac:	8b 45 0c             	mov    0xc(%ebp),%eax
 2af:	89 cb                	mov    %ecx,%ebx
 2b1:	89 df                	mov    %ebx,%edi
 2b3:	89 d1                	mov    %edx,%ecx
 2b5:	fc                   	cld    
 2b6:	f3 aa                	rep stos %al,%es:(%edi)
 2b8:	89 ca                	mov    %ecx,%edx
 2ba:	89 fb                	mov    %edi,%ebx
 2bc:	89 5d 08             	mov    %ebx,0x8(%ebp)
 2bf:	89 55 10             	mov    %edx,0x10(%ebp)
               "=D" (addr), "=c" (cnt) :
               "0" (addr), "1" (cnt), "a" (data) :
               "memory", "cc");
}
 2c2:	90                   	nop
 2c3:	5b                   	pop    %ebx
 2c4:	5f                   	pop    %edi
 2c5:	5d                   	pop    %ebp
 2c6:	c3                   	ret    

000002c7 <strcpy>:
#include "user.h"
#include "x86.h"

char*
strcpy(char *s, char *t)
{
 2c7:	55                   	push   %ebp
 2c8:	89 e5                	mov    %esp,%ebp
 2ca:	83 ec 10             	sub    $0x10,%esp
  char *os;

  os = s;
 2cd:	8b 45 08             	mov    0x8(%ebp),%eax
 2d0:	89 45 fc             	mov    %eax,-0x4(%ebp)
  while((*s++ = *t++) != 0)
 2d3:	90                   	nop
 2d4:	8b 55 0c             	mov    0xc(%ebp),%edx
 2d7:	8d 42 01             	lea    0x1(%edx),%eax
 2da:	89 45 0c             	mov    %eax,0xc(%ebp)
 2dd:	8b 45 08             	mov    0x8(%ebp),%eax
 2e0:	8d 48 01             	lea    0x1(%eax),%ecx
 2e3:	89 4d 08             	mov    %ecx,0x8(%ebp)
 2e6:	0f b6 12             	movzbl (%edx),%edx
 2e9:	88 10                	mov    %dl,(%eax)
 2eb:	0f b6 00             	movzbl (%eax),%eax
 2ee:	84 c0                	test   %al,%al
 2f0:	75 e2                	jne    2d4 <strcpy+0xd>
    ;
  return os;
 2f2:	8b 45 fc             	mov    -0x4(%ebp),%eax
}
 2f5:	c9                   	leave  
 2f6:	c3                   	ret    

000002f7 <strcmp>:

int
strcmp(const char *p, const char *q)
{
 2f7:	55                   	push   %ebp
 2f8:	89 e5                	mov    %esp,%ebp
  while(*p && *p == *q)
 2fa:	eb 08                	jmp    304 <strcmp+0xd>
    p++, q++;
 2fc:	83 45 08 01          	addl   $0x1,0x8(%ebp)
 300:	83 45 0c 01          	addl   $0x1,0xc(%ebp)
  while(*p && *p == *q)
 304:	8b 45 08             	mov    0x8(%ebp),%eax
 307:	0f b6 00             	movzbl (%eax),%eax
 30a:	84 c0                	test   %al,%al
 30c:	74 10                	je     31e <strcmp+0x27>
 30e:	8b 45 08             	mov    0x8(%ebp),%eax
 311:	0f b6 10             	movzbl (%eax),%edx
 314:	8b 45 0c             	mov    0xc(%ebp),%eax
 317:	0f b6 00             	movzbl (%eax),%eax
 31a:	38 c2                	cmp    %al,%dl
 31c:	74 de                	je     2fc <strcmp+0x5>
  return (uchar)*p - (uchar)*q;
 31e:	8b 45 08             	mov    0x8(%ebp),%eax
 321:	0f b6 00             	movzbl (%eax),%eax
 324:	0f b6 d0             	movzbl %al,%edx
 327:	8b 45 0c             	mov    0xc(%ebp),%eax
 32a:	0f b6 00             	movzbl (%eax),%eax
 32d:	0f b6 c8             	movzbl %al,%ecx
 330:	89 d0                	mov    %edx,%eax
 332:	29 c8                	sub    %ecx,%eax
}
 334:	5d                   	pop    %ebp
 335:	c3                   	ret    

00000336 <strlen>:

uint
strlen(char *s)
{
 336:	55                   	push   %ebp
 337:	89 e5                	mov    %esp,%ebp
 339:	83 ec 10             	sub    $0x10,%esp
  int n;

  for(n = 0; s[n]; n++)
 33c:	c7 45 fc 00 00 00 00 	movl   $0x0,-0x4(%ebp)
 343:	eb 04                	jmp    349 <strlen+0x13>
 345:	83 45 fc 01          	addl   $0x1,-0x4(%ebp)
 349:	8b 55 fc             	mov    -0x4(%ebp),%edx
 34c:	8b 45 08             	mov    0x8(%ebp),%eax
 34f:	01 d0                	add    %edx,%eax
 351:	0f b6 00             	movzbl (%eax),%eax
 354:	84 c0                	test   %al,%al
 356:	75 ed                	jne    345 <strlen+0xf>
    ;
  return n;
 358:	8b 45 fc             	mov    -0x4(%ebp),%eax
}
 35b:	c9                   	leave  
 35c:	c3                   	ret    

0000035d <memset>:

void*
memset(void *dst, int c, uint n)
{
 35d:	55                   	push   %ebp
 35e:	89 e5                	mov    %esp,%ebp
  stosb(dst, c, n);
 360:	8b 45 10             	mov    0x10(%ebp),%eax
 363:	50                   	push   %eax
 364:	ff 75 0c             	push   0xc(%ebp)
 367:	ff 75 08             	push   0x8(%ebp)
 36a:	e8 32 ff ff ff       	call   2a1 <stosb>
 36f:	83 c4 0c             	add    $0xc,%esp
  return dst;
 372:	8b 45 08             	mov    0x8(%ebp),%eax
}
 375:	c9                   	leave  
 376:	c3                   	ret    

00000377 <strchr>:

char*
strchr(const char *s, char c)
{
 377:	55                   	push   %ebp
 378:	89 e5                	mov    %esp,%ebp
 37a:	83 ec 04             	sub    $0x4,%esp
 37d:	8b 45 0c             	mov    0xc(%ebp),%eax
 380:	88 45 fc             	mov    %al,-0x4(%ebp)
  for(; *s; s++)
 383:	eb 14                	jmp    399 <strchr+0x22>
    if(*s == c)
 385:	8b 45 08             	mov    0x8(%ebp),%eax
 388:	0f b6 00             	movzbl (%eax),%eax
 38b:	38 45 fc             	cmp    %al,-0x4(%ebp)
 38e:	75 05                	jne    395 <strchr+0x1e>
      return (char*)s;
 390:	8b 45 08             	mov    0x8(%ebp),%eax
 393:	eb 13                	jmp    3a8 <strchr+0x31>
  for(; *s; s++)
 395:	83 45 08 01          	addl   $0x1,0x8(%ebp)
 399:	8b 45 08             	mov    0x8(%ebp),%eax
 39c:	0f b6 00             	movzbl (%eax),%eax
 39f:	84 c0                	test   %al,%al
 3a1:	75 e2                	jne    385 <strchr+0xe>
  return 0;
 3a3:	b8 00 00 00 00       	mov    $0x0,%eax
}
 3a8:	c9                   	leave  
 3a9:	c3                   	ret    

000003aa <gets>:

char*
gets(char *buf, int max)
{
 3aa:	55                   	push   %ebp
 3ab:	89 e5                	mov    %esp,%ebp
 3ad:	83 ec 18             	sub    $0x18,%esp
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 3b0:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
 3b7:	eb 42                	jmp    3fb <gets+0x51>
    cc = read(0, &c, 1);
 3b9:	83 ec 04             	sub    $0x4,%esp
 3bc:	6a 01                	push   $0x1
 3be:	8d 45 ef             	lea    -0x11(%ebp),%eax
 3c1:	50                   	push   %eax
 3c2:	6a 00                	push   $0x0
 3c4:	e8 47 01 00 00       	call   510 <read>
 3c9:	83 c4 10             	add    $0x10,%esp
 3cc:	89 45 f0             	mov    %eax,-0x10(%ebp)
    if(cc < 1)
 3cf:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
 3d3:	7e 33                	jle    408 <gets+0x5e>
      break;
    buf[i++] = c;
 3d5:	8b 45 f4             	mov    -0xc(%ebp),%eax
 3d8:	8d 50 01             	lea    0x1(%eax),%edx
 3db:	89 55 f4             	mov    %edx,-0xc(%ebp)
 3de:	89 c2                	mov    %eax,%edx
 3e0:	8b 45 08             	mov    0x8(%ebp),%eax
 3e3:	01 c2                	add    %eax,%edx
 3e5:	0f b6 45 ef          	movzbl -0x11(%ebp),%eax
 3e9:	88 02                	mov    %al,(%edx)
    if(c == '\n' || c == '\r')
 3eb:	0f b6 45 ef          	movzbl -0x11(%ebp),%eax
 3ef:	3c 0a                	cmp    $0xa,%al
 3f1:	74 16                	je     409 <gets+0x5f>
 3f3:	0f b6 45 ef          	movzbl -0x11(%ebp),%eax
 3f7:	3c 0d                	cmp    $0xd,%al
 3f9:	74 0e                	je     409 <gets+0x5f>
  for(i=0; i+1 < max; ){
 3fb:	8b 45 f4             	mov    -0xc(%ebp),%eax
 3fe:	83 c0 01             	add    $0x1,%eax
 401:	39 45 0c             	cmp    %eax,0xc(%ebp)
 404:	7f b3                	jg     3b9 <gets+0xf>
 406:	eb 01                	jmp    409 <gets+0x5f>
      break;
 408:	90                   	nop
      break;
  }
  buf[i] = '\0';
 409:	8b 55 f4             	mov    -0xc(%ebp),%edx
 40c:	8b 45 08             	mov    0x8(%ebp),%eax
 40f:	01 d0                	add    %edx,%eax
 411:	c6 00 00             	movb   $0x0,(%eax)
  return buf;
 414:	8b 45 08             	mov    0x8(%ebp),%eax
}
 417:	c9                   	leave  
 418:	c3                   	ret    

00000419 <stat>:

int
stat(char *n, struct stat *st)
{
 419:	55                   	push   %ebp
 41a:	89 e5                	mov    %esp,%ebp
 41c:	83 ec 18             	sub    $0x18,%esp
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 41f:	83 ec 08             	sub    $0x8,%esp
 422:	6a 00                	push   $0x0
 424:	ff 75 08             	push   0x8(%ebp)
 427:	e8 0c 01 00 00       	call   538 <open>
 42c:	83 c4 10             	add    $0x10,%esp
 42f:	89 45 f4             	mov    %eax,-0xc(%ebp)
  if(fd < 0)
 432:	83 7d f4 00          	cmpl   $0x0,-0xc(%ebp)
 436:	79 07                	jns    43f <stat+0x26>
    return -1;
 438:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
 43d:	eb 25                	jmp    464 <stat+0x4b>
  r = fstat(fd, st);
 43f:	83 ec 08             	sub    $0x8,%esp
 442:	ff 75 0c             	push   0xc(%ebp)
 445:	ff 75 f4             	push   -0xc(%ebp)
 448:	e8 03 01 00 00       	call   550 <fstat>
 44d:	83 c4 10             	add    $0x10,%esp
 450:	89 45 f0             	mov    %eax,-0x10(%ebp)
  close(fd);
 453:	83 ec 0c             	sub    $0xc,%esp
 456:	ff 75 f4             	push   -0xc(%ebp)
 459:	e8 c2 00 00 00       	call   520 <close>
 45e:	83 c4 10             	add    $0x10,%esp
  return r;
 461:	8b 45 f0             	mov    -0x10(%ebp),%eax
}
 464:	c9                   	leave  
 465:	c3                   	ret    

00000466 <atoi>:

int
atoi(const char *s)
{
 466:	55                   	push   %ebp
 467:	89 e5                	mov    %esp,%ebp
 469:	83 ec 10             	sub    $0x10,%esp
  int n;

  n = 0;
 46c:	c7 45 fc 00 00 00 00 	movl   $0x0,-0x4(%ebp)
  while('0' <= *s && *s <= '9')
 473:	eb 25                	jmp    49a <atoi+0x34>
    n = n*10 + *s++ - '0';
 475:	8b 55 fc             	mov    -0x4(%ebp),%edx
 478:	89 d0                	mov    %edx,%eax
 47a:	c1 e0 02             	shl    $0x2,%eax
 47d:	01 d0                	add    %edx,%eax
 47f:	01 c0                	add    %eax,%eax
 481:	89 c1                	mov    %eax,%ecx
 483:	8b 45 08             	mov    0x8(%ebp),%eax
 486:	8d 50 01             	lea    0x1(%eax),%edx
 489:	89 55 08             	mov    %edx,0x8(%ebp)
 48c:	0f b6 00             	movzbl (%eax),%eax
 48f:	0f be c0             	movsbl %al,%eax
 492:	01 c8                	add    %ecx,%eax
 494:	83 e8 30             	sub    $0x30,%eax
 497:	89 45 fc             	mov    %eax,-0x4(%ebp)
  while('0' <= *s && *s <= '9')
 49a:	8b 45 08             	mov    0x8(%ebp),%eax
 49d:	0f b6 00             	movzbl (%eax),%eax
 4a0:	3c 2f                	cmp    $0x2f,%al
 4a2:	7e 0a                	jle    4ae <atoi+0x48>
 4a4:	8b 45 08             	mov    0x8(%ebp),%eax
 4a7:	0f b6 00             	movzbl (%eax),%eax
 4aa:	3c 39                	cmp    $0x39,%al
 4ac:	7e c7                	jle    475 <atoi+0xf>
  return n;
 4ae:	8b 45 fc             	mov    -0x4(%ebp),%eax
}
 4b1:	c9                   	leave  
 4b2:	c3                   	ret    

000004b3 <memmove>:

void*
memmove(void *vdst, void *vsrc, int n)
{
 4b3:	55                   	push   %ebp
 4b4:	89 e5                	mov    %esp,%ebp
 4b6:	83 ec 10             	sub    $0x10,%esp
  char *dst, *src;

  dst = vdst;
 4b9:	8b 45 08             	mov    0x8(%ebp),%eax
 4bc:	89 45 fc             	mov    %eax,-0x4(%ebp)
  src = vsrc;
 4bf:	8b 45 0c             	mov    0xc(%ebp),%eax
 4c2:	89 45 f8             	mov    %eax,-0x8(%ebp)
  while(n-- > 0)
 4c5:	eb 17                	jmp    4de <memmove+0x2b>
    *dst++ = *src++;
 4c7:	8b 55 f8             	mov    -0x8(%ebp),%edx
 4ca:	8d 42 01             	lea    0x1(%edx),%eax
 4cd:	89 45 f8             	mov    %eax,-0x8(%ebp)
 4d0:	8b 45 fc             	mov    -0x4(%ebp),%eax
 4d3:	8d 48 01             	lea    0x1(%eax),%ecx
 4d6:	89 4d fc             	mov    %ecx,-0x4(%ebp)
 4d9:	0f b6 12             	movzbl (%edx),%edx
 4dc:	88 10                	mov    %dl,(%eax)
  while(n-- > 0)
 4de:	8b 45 10             	mov    0x10(%ebp),%eax
 4e1:	8d 50 ff             	lea    -0x1(%eax),%edx
 4e4:	89 55 10             	mov    %edx,0x10(%ebp)
 4e7:	85 c0                	test   %eax,%eax
 4e9:	7f dc                	jg     4c7 <memmove+0x14>
  return vdst;
 4eb:	8b 45 08             	mov    0x8(%ebp),%eax
}
 4ee:	c9                   	leave  
 4ef:	c3                   	ret    

000004f0 <fork>:
  name: \
    movl $SYS_ ## name, %eax; \
    int $T_SYSCALL; \
    ret

SYSCALL(fork)
 4f0:	b8 01 00 00 00       	mov    $0x1,%eax
 4f5:	cd 40                	int    $0x40
 4f7:	c3                   	ret    

000004f8 <exit>:
SYSCALL(exit)
 4f8:	b8 02 00 00 00       	mov    $0x2,%eax
 4fd:	cd 40                	int    $0x40
 4ff:	c3                   	ret    

00000500 <wait>:
SYSCALL(wait)
 500:	b8 03 00 00 00       	mov    $0x3,%eax
 505:	cd 40                	int    $0x40
 507:	c3                   	ret    

00000508 <pipe>:
SYSCALL(pipe)
 508:	b8 04 00 00 00       	mov    $0x4,%eax
 50d:	cd 40                	int    $0x40
 50f:	c3                   	ret    

00000510 <read>:
SYSCALL(read)
 510:	b8 05 00 00 00       	mov    $0x5,%eax
 515:	cd 40                	int    $0x40
 517:	c3                   	ret    

00000518 <write>:
SYSCALL(write)
 518:	b8 10 00 00 00       	mov    $0x10,%eax
 51d:	cd 40                	int    $0x40
 51f:	c3                   	ret    

00000520 <close>:
SYSCALL(close)
 520:	b8 15 00 00 00       	mov    $0x15,%eax
 525:	cd 40                	int    $0x40
 527:	c3                   	ret    

00000528 <kill>:
SYSCALL(kill)
 528:	b8 06 00 00 00       	mov    $0x6,%eax
 52d:	cd 40                	int    $0x40
 52f:	c3                   	ret    

00000530 <exec>:
SYSCALL(exec)
 530:	b8 07 00 00 00       	mov    $0x7,%eax
 535:	cd 40                	int    $0x40
 537:	c3                   	ret    

00000538 <open>:
SYSCALL(open)
 538:	b8 0f 00 00 00       	mov    $0xf,%eax
 53d:	cd 40                	int    $0x40
 53f:	c3                   	ret    

00000540 <mknod>:
SYSCALL(mknod)
 540:	b8 11 00 00 00       	mov    $0x11,%eax
 545:	cd 40                	int    $0x40
 547:	c3                   	ret    

00000548 <unlink>:
SYSCALL(unlink)
 548:	b8 12 00 00 00       	mov    $0x12,%eax
 54d:	cd 40                	int    $0x40
 54f:	c3                   	ret    

00000550 <fstat>:
SYSCALL(fstat)
 550:	b8 08 00 00 00       	mov    $0x8,%eax
 555:	cd 40                	int    $0x40
 557:	c3                   	ret    

00000558 <link>:
SYSCALL(link)
 558:	b8 13 00 00 00       	mov    $0x13,%eax
 55d:	cd 40                	int    $0x40
 55f:	c3                   	ret    

00000560 <mkdir>:
SYSCALL(mkdir)
 560:	b8 14 00 00 00       	mov    $0x14,%eax
 565:	cd 40                	int    $0x40
 567:	c3                   	ret    

00000568 <chdir>:
SYSCALL(chdir)
 568:	b8 09 00 00 00       	mov    $0x9,%eax
 56d:	cd 40                	int    $0x40
 56f:	c3                   	ret    

00000570 <dup>:
SYSCALL(dup)
 570:	b8 0a 00 00 00       	mov    $0xa,%eax
 575:	cd 40                	int    $0x40
 577:	c3                   	ret    

00000578 <getpid>:
SYSCALL(getpid)
 578:	b8 0b 00 00 00       	mov    $0xb,%eax
 57d:	cd 40                	int    $0x40
 57f:	c3                   	ret    

00000580 <sbrk>:
SYSCALL(sbrk)
 580:	b8 0c 00 00 00       	mov    $0xc,%eax
 585:	cd 40                	int    $0x40
 587:	c3                   	ret    

00000588 <sleep>:
SYSCALL(sleep)
 588:	b8 0d 00 00 00       	mov    $0xd,%eax
 58d:	cd 40                	int    $0x40
 58f:	c3                   	ret    

00000590 <uptime>:
SYSCALL(uptime)
 590:	b8 0e 00 00 00       	mov    $0xe,%eax
 595:	cd 40                	int    $0x40
 597:	c3                   	ret    

00000598 <shutdown>:
SYSCALL(shutdown)
 598:	b8 16 00 00 00       	mov    $0x16,%eax
 59d:	cd 40                	int    $0x40
 59f:	c3                   	ret    

000005a0 <get_free_frame_cnt>:
SYSCALL(get_free_frame_cnt)
 5a0:	b8 17 00 00 00       	mov    $0x17,%eax
 5a5:	cd 40                	int    $0x40
 5a7:	c3                   	ret    

000005a8 <putc>:
#include "stat.h"
#include "user.h"

static void
putc(int fd, char c)
{
 5a8:	55                   	push   %ebp
 5a9:	89 e5                	mov    %esp,%ebp
 5ab:	83 ec 18             	sub    $0x18,%esp
 5ae:	8b 45 0c             	mov    0xc(%ebp),%eax
 5b1:	88 45 f4             	mov    %al,-0xc(%ebp)
  write(fd, &c, 1);
 5b4:	83 ec 04             	sub    $0x4,%esp
 5b7:	6a 01                	push   $0x1
 5b9:	8d 45 f4             	lea    -0xc(%ebp),%eax
 5bc:	50                   	push   %eax
 5bd:	ff 75 08             	push   0x8(%ebp)
 5c0:	e8 53 ff ff ff       	call   518 <write>
 5c5:	83 c4 10             	add    $0x10,%esp
}
 5c8:	90                   	nop
 5c9:	c9                   	leave  
 5ca:	c3                   	ret    

000005cb <printint>:

static void
printint(int fd, int xx, int base, int sgn)
{
 5cb:	55                   	push   %ebp
 5cc:	89 e5                	mov    %esp,%ebp
 5ce:	83 ec 28             	sub    $0x28,%esp
  static char digits[] = "0123456789ABCDEF";
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
 5d1:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  if(sgn && xx < 0){
 5d8:	83 7d 14 00          	cmpl   $0x0,0x14(%ebp)
 5dc:	74 17                	je     5f5 <printint+0x2a>
 5de:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
 5e2:	79 11                	jns    5f5 <printint+0x2a>
    neg = 1;
 5e4:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)
    x = -xx;
 5eb:	8b 45 0c             	mov    0xc(%ebp),%eax
 5ee:	f7 d8                	neg    %eax
 5f0:	89 45 ec             	mov    %eax,-0x14(%ebp)
 5f3:	eb 06                	jmp    5fb <printint+0x30>
  } else {
    x = xx;
 5f5:	8b 45 0c             	mov    0xc(%ebp),%eax
 5f8:	89 45 ec             	mov    %eax,-0x14(%ebp)
  }

  i = 0;
 5fb:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  do{
    buf[i++] = digits[x % base];
 602:	8b 4d 10             	mov    0x10(%ebp),%ecx
 605:	8b 45 ec             	mov    -0x14(%ebp),%eax
 608:	ba 00 00 00 00       	mov    $0x0,%edx
 60d:	f7 f1                	div    %ecx
 60f:	89 d1                	mov    %edx,%ecx
 611:	8b 45 f4             	mov    -0xc(%ebp),%eax
 614:	8d 50 01             	lea    0x1(%eax),%edx
 617:	89 55 f4             	mov    %edx,-0xc(%ebp)
 61a:	0f b6 91 a4 0d 00 00 	movzbl 0xda4(%ecx),%edx
 621:	88 54 05 dc          	mov    %dl,-0x24(%ebp,%eax,1)
  }while((x /= base) != 0);
 625:	8b 4d 10             	mov    0x10(%ebp),%ecx
 628:	8b 45 ec             	mov    -0x14(%ebp),%eax
 62b:	ba 00 00 00 00       	mov    $0x0,%edx
 630:	f7 f1                	div    %ecx
 632:	89 45 ec             	mov    %eax,-0x14(%ebp)
 635:	83 7d ec 00          	cmpl   $0x0,-0x14(%ebp)
 639:	75 c7                	jne    602 <printint+0x37>
  if(neg)
 63b:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
 63f:	74 2d                	je     66e <printint+0xa3>
    buf[i++] = '-';
 641:	8b 45 f4             	mov    -0xc(%ebp),%eax
 644:	8d 50 01             	lea    0x1(%eax),%edx
 647:	89 55 f4             	mov    %edx,-0xc(%ebp)
 64a:	c6 44 05 dc 2d       	movb   $0x2d,-0x24(%ebp,%eax,1)

  while(--i >= 0)
 64f:	eb 1d                	jmp    66e <printint+0xa3>
    putc(fd, buf[i]);
 651:	8d 55 dc             	lea    -0x24(%ebp),%edx
 654:	8b 45 f4             	mov    -0xc(%ebp),%eax
 657:	01 d0                	add    %edx,%eax
 659:	0f b6 00             	movzbl (%eax),%eax
 65c:	0f be c0             	movsbl %al,%eax
 65f:	83 ec 08             	sub    $0x8,%esp
 662:	50                   	push   %eax
 663:	ff 75 08             	push   0x8(%ebp)
 666:	e8 3d ff ff ff       	call   5a8 <putc>
 66b:	83 c4 10             	add    $0x10,%esp
  while(--i >= 0)
 66e:	83 6d f4 01          	subl   $0x1,-0xc(%ebp)
 672:	83 7d f4 00          	cmpl   $0x0,-0xc(%ebp)
 676:	79 d9                	jns    651 <printint+0x86>
}
 678:	90                   	nop
 679:	90                   	nop
 67a:	c9                   	leave  
 67b:	c3                   	ret    

0000067c <printf>:

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
 67c:	55                   	push   %ebp
 67d:	89 e5                	mov    %esp,%ebp
 67f:	83 ec 28             	sub    $0x28,%esp
  char *s;
  int c, i, state;
  uint *ap;

  state = 0;
 682:	c7 45 ec 00 00 00 00 	movl   $0x0,-0x14(%ebp)
  ap = (uint*)(void*)&fmt + 1;
 689:	8d 45 0c             	lea    0xc(%ebp),%eax
 68c:	83 c0 04             	add    $0x4,%eax
 68f:	89 45 e8             	mov    %eax,-0x18(%ebp)
  for(i = 0; fmt[i]; i++){
 692:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
 699:	e9 59 01 00 00       	jmp    7f7 <printf+0x17b>
    c = fmt[i] & 0xff;
 69e:	8b 55 0c             	mov    0xc(%ebp),%edx
 6a1:	8b 45 f0             	mov    -0x10(%ebp),%eax
 6a4:	01 d0                	add    %edx,%eax
 6a6:	0f b6 00             	movzbl (%eax),%eax
 6a9:	0f be c0             	movsbl %al,%eax
 6ac:	25 ff 00 00 00       	and    $0xff,%eax
 6b1:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    if(state == 0){
 6b4:	83 7d ec 00          	cmpl   $0x0,-0x14(%ebp)
 6b8:	75 2c                	jne    6e6 <printf+0x6a>
      if(c == '%'){
 6ba:	83 7d e4 25          	cmpl   $0x25,-0x1c(%ebp)
 6be:	75 0c                	jne    6cc <printf+0x50>
        state = '%';
 6c0:	c7 45 ec 25 00 00 00 	movl   $0x25,-0x14(%ebp)
 6c7:	e9 27 01 00 00       	jmp    7f3 <printf+0x177>
      } else {
        putc(fd, c);
 6cc:	8b 45 e4             	mov    -0x1c(%ebp),%eax
 6cf:	0f be c0             	movsbl %al,%eax
 6d2:	83 ec 08             	sub    $0x8,%esp
 6d5:	50                   	push   %eax
 6d6:	ff 75 08             	push   0x8(%ebp)
 6d9:	e8 ca fe ff ff       	call   5a8 <putc>
 6de:	83 c4 10             	add    $0x10,%esp
 6e1:	e9 0d 01 00 00       	jmp    7f3 <printf+0x177>
      }
    } else if(state == '%'){
 6e6:	83 7d ec 25          	cmpl   $0x25,-0x14(%ebp)
 6ea:	0f 85 03 01 00 00    	jne    7f3 <printf+0x177>
      if(c == 'd'){
 6f0:	83 7d e4 64          	cmpl   $0x64,-0x1c(%ebp)
 6f4:	75 1e                	jne    714 <printf+0x98>
        printint(fd, *ap, 10, 1);
 6f6:	8b 45 e8             	mov    -0x18(%ebp),%eax
 6f9:	8b 00                	mov    (%eax),%eax
 6fb:	6a 01                	push   $0x1
 6fd:	6a 0a                	push   $0xa
 6ff:	50                   	push   %eax
 700:	ff 75 08             	push   0x8(%ebp)
 703:	e8 c3 fe ff ff       	call   5cb <printint>
 708:	83 c4 10             	add    $0x10,%esp
        ap++;
 70b:	83 45 e8 04          	addl   $0x4,-0x18(%ebp)
 70f:	e9 d8 00 00 00       	jmp    7ec <printf+0x170>
      } else if(c == 'x' || c == 'p'){
 714:	83 7d e4 78          	cmpl   $0x78,-0x1c(%ebp)
 718:	74 06                	je     720 <printf+0xa4>
 71a:	83 7d e4 70          	cmpl   $0x70,-0x1c(%ebp)
 71e:	75 1e                	jne    73e <printf+0xc2>
        printint(fd, *ap, 16, 0);
 720:	8b 45 e8             	mov    -0x18(%ebp),%eax
 723:	8b 00                	mov    (%eax),%eax
 725:	6a 00                	push   $0x0
 727:	6a 10                	push   $0x10
 729:	50                   	push   %eax
 72a:	ff 75 08             	push   0x8(%ebp)
 72d:	e8 99 fe ff ff       	call   5cb <printint>
 732:	83 c4 10             	add    $0x10,%esp
        ap++;
 735:	83 45 e8 04          	addl   $0x4,-0x18(%ebp)
 739:	e9 ae 00 00 00       	jmp    7ec <printf+0x170>
      } else if(c == 's'){
 73e:	83 7d e4 73          	cmpl   $0x73,-0x1c(%ebp)
 742:	75 43                	jne    787 <printf+0x10b>
        s = (char*)*ap;
 744:	8b 45 e8             	mov    -0x18(%ebp),%eax
 747:	8b 00                	mov    (%eax),%eax
 749:	89 45 f4             	mov    %eax,-0xc(%ebp)
        ap++;
 74c:	83 45 e8 04          	addl   $0x4,-0x18(%ebp)
        if(s == 0)
 750:	83 7d f4 00          	cmpl   $0x0,-0xc(%ebp)
 754:	75 25                	jne    77b <printf+0xff>
          s = "(null)";
 756:	c7 45 f4 57 0b 00 00 	movl   $0xb57,-0xc(%ebp)
        while(*s != 0){
 75d:	eb 1c                	jmp    77b <printf+0xff>
          putc(fd, *s);
 75f:	8b 45 f4             	mov    -0xc(%ebp),%eax
 762:	0f b6 00             	movzbl (%eax),%eax
 765:	0f be c0             	movsbl %al,%eax
 768:	83 ec 08             	sub    $0x8,%esp
 76b:	50                   	push   %eax
 76c:	ff 75 08             	push   0x8(%ebp)
 76f:	e8 34 fe ff ff       	call   5a8 <putc>
 774:	83 c4 10             	add    $0x10,%esp
          s++;
 777:	83 45 f4 01          	addl   $0x1,-0xc(%ebp)
        while(*s != 0){
 77b:	8b 45 f4             	mov    -0xc(%ebp),%eax
 77e:	0f b6 00             	movzbl (%eax),%eax
 781:	84 c0                	test   %al,%al
 783:	75 da                	jne    75f <printf+0xe3>
 785:	eb 65                	jmp    7ec <printf+0x170>
        }
      } else if(c == 'c'){
 787:	83 7d e4 63          	cmpl   $0x63,-0x1c(%ebp)
 78b:	75 1d                	jne    7aa <printf+0x12e>
        putc(fd, *ap);
 78d:	8b 45 e8             	mov    -0x18(%ebp),%eax
 790:	8b 00                	mov    (%eax),%eax
 792:	0f be c0             	movsbl %al,%eax
 795:	83 ec 08             	sub    $0x8,%esp
 798:	50                   	push   %eax
 799:	ff 75 08             	push   0x8(%ebp)
 79c:	e8 07 fe ff ff       	call   5a8 <putc>
 7a1:	83 c4 10             	add    $0x10,%esp
        ap++;
 7a4:	83 45 e8 04          	addl   $0x4,-0x18(%ebp)
 7a8:	eb 42                	jmp    7ec <printf+0x170>
      } else if(c == '%'){
 7aa:	83 7d e4 25          	cmpl   $0x25,-0x1c(%ebp)
 7ae:	75 17                	jne    7c7 <printf+0x14b>
        putc(fd, c);
 7b0:	8b 45 e4             	mov    -0x1c(%ebp),%eax
 7b3:	0f be c0             	movsbl %al,%eax
 7b6:	83 ec 08             	sub    $0x8,%esp
 7b9:	50                   	push   %eax
 7ba:	ff 75 08             	push   0x8(%ebp)
 7bd:	e8 e6 fd ff ff       	call   5a8 <putc>
 7c2:	83 c4 10             	add    $0x10,%esp
 7c5:	eb 25                	jmp    7ec <printf+0x170>
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
 7c7:	83 ec 08             	sub    $0x8,%esp
 7ca:	6a 25                	push   $0x25
 7cc:	ff 75 08             	push   0x8(%ebp)
 7cf:	e8 d4 fd ff ff       	call   5a8 <putc>
 7d4:	83 c4 10             	add    $0x10,%esp
        putc(fd, c);
 7d7:	8b 45 e4             	mov    -0x1c(%ebp),%eax
 7da:	0f be c0             	movsbl %al,%eax
 7dd:	83 ec 08             	sub    $0x8,%esp
 7e0:	50                   	push   %eax
 7e1:	ff 75 08             	push   0x8(%ebp)
 7e4:	e8 bf fd ff ff       	call   5a8 <putc>
 7e9:	83 c4 10             	add    $0x10,%esp
      }
      state = 0;
 7ec:	c7 45 ec 00 00 00 00 	movl   $0x0,-0x14(%ebp)
  for(i = 0; fmt[i]; i++){
 7f3:	83 45 f0 01          	addl   $0x1,-0x10(%ebp)
 7f7:	8b 55 0c             	mov    0xc(%ebp),%edx
 7fa:	8b 45 f0             	mov    -0x10(%ebp),%eax
 7fd:	01 d0                	add    %edx,%eax
 7ff:	0f b6 00             	movzbl (%eax),%eax
 802:	84 c0                	test   %al,%al
 804:	0f 85 94 fe ff ff    	jne    69e <printf+0x22>
    }
  }
}
 80a:	90                   	nop
 80b:	90                   	nop
 80c:	c9                   	leave  
 80d:	c3                   	ret    

0000080e <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
 80e:	55                   	push   %ebp
 80f:	89 e5                	mov    %esp,%ebp
 811:	83 ec 10             	sub    $0x10,%esp
  Header *bp, *p;

  bp = (Header*)ap - 1;
 814:	8b 45 08             	mov    0x8(%ebp),%eax
 817:	83 e8 08             	sub    $0x8,%eax
 81a:	89 45 f8             	mov    %eax,-0x8(%ebp)
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 81d:	a1 c0 0d 00 00       	mov    0xdc0,%eax
 822:	89 45 fc             	mov    %eax,-0x4(%ebp)
 825:	eb 24                	jmp    84b <free+0x3d>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 827:	8b 45 fc             	mov    -0x4(%ebp),%eax
 82a:	8b 00                	mov    (%eax),%eax
 82c:	39 45 fc             	cmp    %eax,-0x4(%ebp)
 82f:	72 12                	jb     843 <free+0x35>
 831:	8b 45 f8             	mov    -0x8(%ebp),%eax
 834:	3b 45 fc             	cmp    -0x4(%ebp),%eax
 837:	77 24                	ja     85d <free+0x4f>
 839:	8b 45 fc             	mov    -0x4(%ebp),%eax
 83c:	8b 00                	mov    (%eax),%eax
 83e:	39 45 f8             	cmp    %eax,-0x8(%ebp)
 841:	72 1a                	jb     85d <free+0x4f>
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 843:	8b 45 fc             	mov    -0x4(%ebp),%eax
 846:	8b 00                	mov    (%eax),%eax
 848:	89 45 fc             	mov    %eax,-0x4(%ebp)
 84b:	8b 45 f8             	mov    -0x8(%ebp),%eax
 84e:	3b 45 fc             	cmp    -0x4(%ebp),%eax
 851:	76 d4                	jbe    827 <free+0x19>
 853:	8b 45 fc             	mov    -0x4(%ebp),%eax
 856:	8b 00                	mov    (%eax),%eax
 858:	39 45 f8             	cmp    %eax,-0x8(%ebp)
 85b:	73 ca                	jae    827 <free+0x19>
      break;
  if(bp + bp->s.size == p->s.ptr){
 85d:	8b 45 f8             	mov    -0x8(%ebp),%eax
 860:	8b 40 04             	mov    0x4(%eax),%eax
 863:	8d 14 c5 00 00 00 00 	lea    0x0(,%eax,8),%edx
 86a:	8b 45 f8             	mov    -0x8(%ebp),%eax
 86d:	01 c2                	add    %eax,%edx
 86f:	8b 45 fc             	mov    -0x4(%ebp),%eax
 872:	8b 00                	mov    (%eax),%eax
 874:	39 c2                	cmp    %eax,%edx
 876:	75 24                	jne    89c <free+0x8e>
    bp->s.size += p->s.ptr->s.size;
 878:	8b 45 f8             	mov    -0x8(%ebp),%eax
 87b:	8b 50 04             	mov    0x4(%eax),%edx
 87e:	8b 45 fc             	mov    -0x4(%ebp),%eax
 881:	8b 00                	mov    (%eax),%eax
 883:	8b 40 04             	mov    0x4(%eax),%eax
 886:	01 c2                	add    %eax,%edx
 888:	8b 45 f8             	mov    -0x8(%ebp),%eax
 88b:	89 50 04             	mov    %edx,0x4(%eax)
    bp->s.ptr = p->s.ptr->s.ptr;
 88e:	8b 45 fc             	mov    -0x4(%ebp),%eax
 891:	8b 00                	mov    (%eax),%eax
 893:	8b 10                	mov    (%eax),%edx
 895:	8b 45 f8             	mov    -0x8(%ebp),%eax
 898:	89 10                	mov    %edx,(%eax)
 89a:	eb 0a                	jmp    8a6 <free+0x98>
  } else
    bp->s.ptr = p->s.ptr;
 89c:	8b 45 fc             	mov    -0x4(%ebp),%eax
 89f:	8b 10                	mov    (%eax),%edx
 8a1:	8b 45 f8             	mov    -0x8(%ebp),%eax
 8a4:	89 10                	mov    %edx,(%eax)
  if(p + p->s.size == bp){
 8a6:	8b 45 fc             	mov    -0x4(%ebp),%eax
 8a9:	8b 40 04             	mov    0x4(%eax),%eax
 8ac:	8d 14 c5 00 00 00 00 	lea    0x0(,%eax,8),%edx
 8b3:	8b 45 fc             	mov    -0x4(%ebp),%eax
 8b6:	01 d0                	add    %edx,%eax
 8b8:	39 45 f8             	cmp    %eax,-0x8(%ebp)
 8bb:	75 20                	jne    8dd <free+0xcf>
    p->s.size += bp->s.size;
 8bd:	8b 45 fc             	mov    -0x4(%ebp),%eax
 8c0:	8b 50 04             	mov    0x4(%eax),%edx
 8c3:	8b 45 f8             	mov    -0x8(%ebp),%eax
 8c6:	8b 40 04             	mov    0x4(%eax),%eax
 8c9:	01 c2                	add    %eax,%edx
 8cb:	8b 45 fc             	mov    -0x4(%ebp),%eax
 8ce:	89 50 04             	mov    %edx,0x4(%eax)
    p->s.ptr = bp->s.ptr;
 8d1:	8b 45 f8             	mov    -0x8(%ebp),%eax
 8d4:	8b 10                	mov    (%eax),%edx
 8d6:	8b 45 fc             	mov    -0x4(%ebp),%eax
 8d9:	89 10                	mov    %edx,(%eax)
 8db:	eb 08                	jmp    8e5 <free+0xd7>
  } else
    p->s.ptr = bp;
 8dd:	8b 45 fc             	mov    -0x4(%ebp),%eax
 8e0:	8b 55 f8             	mov    -0x8(%ebp),%edx
 8e3:	89 10                	mov    %edx,(%eax)
  freep = p;
 8e5:	8b 45 fc             	mov    -0x4(%ebp),%eax
 8e8:	a3 c0 0d 00 00       	mov    %eax,0xdc0
}
 8ed:	90                   	nop
 8ee:	c9                   	leave  
 8ef:	c3                   	ret    

000008f0 <morecore>:

static Header*
morecore(uint nu)
{
 8f0:	55                   	push   %ebp
 8f1:	89 e5                	mov    %esp,%ebp
 8f3:	83 ec 18             	sub    $0x18,%esp
  char *p;
  Header *hp;

  if(nu < 4096)
 8f6:	81 7d 08 ff 0f 00 00 	cmpl   $0xfff,0x8(%ebp)
 8fd:	77 07                	ja     906 <morecore+0x16>
    nu = 4096;
 8ff:	c7 45 08 00 10 00 00 	movl   $0x1000,0x8(%ebp)
  p = sbrk(nu * sizeof(Header));
 906:	8b 45 08             	mov    0x8(%ebp),%eax
 909:	c1 e0 03             	shl    $0x3,%eax
 90c:	83 ec 0c             	sub    $0xc,%esp
 90f:	50                   	push   %eax
 910:	e8 6b fc ff ff       	call   580 <sbrk>
 915:	83 c4 10             	add    $0x10,%esp
 918:	89 45 f4             	mov    %eax,-0xc(%ebp)
  if(p == (char*)-1)
 91b:	83 7d f4 ff          	cmpl   $0xffffffff,-0xc(%ebp)
 91f:	75 07                	jne    928 <morecore+0x38>
    return 0;
 921:	b8 00 00 00 00       	mov    $0x0,%eax
 926:	eb 26                	jmp    94e <morecore+0x5e>
  hp = (Header*)p;
 928:	8b 45 f4             	mov    -0xc(%ebp),%eax
 92b:	89 45 f0             	mov    %eax,-0x10(%ebp)
  hp->s.size = nu;
 92e:	8b 45 f0             	mov    -0x10(%ebp),%eax
 931:	8b 55 08             	mov    0x8(%ebp),%edx
 934:	89 50 04             	mov    %edx,0x4(%eax)
  free((void*)(hp + 1));
 937:	8b 45 f0             	mov    -0x10(%ebp),%eax
 93a:	83 c0 08             	add    $0x8,%eax
 93d:	83 ec 0c             	sub    $0xc,%esp
 940:	50                   	push   %eax
 941:	e8 c8 fe ff ff       	call   80e <free>
 946:	83 c4 10             	add    $0x10,%esp
  return freep;
 949:	a1 c0 0d 00 00       	mov    0xdc0,%eax
}
 94e:	c9                   	leave  
 94f:	c3                   	ret    

00000950 <malloc>:

void*
malloc(uint nbytes)
{
 950:	55                   	push   %ebp
 951:	89 e5                	mov    %esp,%ebp
 953:	83 ec 18             	sub    $0x18,%esp
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 956:	8b 45 08             	mov    0x8(%ebp),%eax
 959:	83 c0 07             	add    $0x7,%eax
 95c:	c1 e8 03             	shr    $0x3,%eax
 95f:	83 c0 01             	add    $0x1,%eax
 962:	89 45 ec             	mov    %eax,-0x14(%ebp)
  if((prevp = freep) == 0){
 965:	a1 c0 0d 00 00       	mov    0xdc0,%eax
 96a:	89 45 f0             	mov    %eax,-0x10(%ebp)
 96d:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
 971:	75 23                	jne    996 <malloc+0x46>
    base.s.ptr = freep = prevp = &base;
 973:	c7 45 f0 b8 0d 00 00 	movl   $0xdb8,-0x10(%ebp)
 97a:	8b 45 f0             	mov    -0x10(%ebp),%eax
 97d:	a3 c0 0d 00 00       	mov    %eax,0xdc0
 982:	a1 c0 0d 00 00       	mov    0xdc0,%eax
 987:	a3 b8 0d 00 00       	mov    %eax,0xdb8
    base.s.size = 0;
 98c:	c7 05 bc 0d 00 00 00 	movl   $0x0,0xdbc
 993:	00 00 00 
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 996:	8b 45 f0             	mov    -0x10(%ebp),%eax
 999:	8b 00                	mov    (%eax),%eax
 99b:	89 45 f4             	mov    %eax,-0xc(%ebp)
    if(p->s.size >= nunits){
 99e:	8b 45 f4             	mov    -0xc(%ebp),%eax
 9a1:	8b 40 04             	mov    0x4(%eax),%eax
 9a4:	39 45 ec             	cmp    %eax,-0x14(%ebp)
 9a7:	77 4d                	ja     9f6 <malloc+0xa6>
      if(p->s.size == nunits)
 9a9:	8b 45 f4             	mov    -0xc(%ebp),%eax
 9ac:	8b 40 04             	mov    0x4(%eax),%eax
 9af:	39 45 ec             	cmp    %eax,-0x14(%ebp)
 9b2:	75 0c                	jne    9c0 <malloc+0x70>
        prevp->s.ptr = p->s.ptr;
 9b4:	8b 45 f4             	mov    -0xc(%ebp),%eax
 9b7:	8b 10                	mov    (%eax),%edx
 9b9:	8b 45 f0             	mov    -0x10(%ebp),%eax
 9bc:	89 10                	mov    %edx,(%eax)
 9be:	eb 26                	jmp    9e6 <malloc+0x96>
      else {
        p->s.size -= nunits;
 9c0:	8b 45 f4             	mov    -0xc(%ebp),%eax
 9c3:	8b 40 04             	mov    0x4(%eax),%eax
 9c6:	2b 45 ec             	sub    -0x14(%ebp),%eax
 9c9:	89 c2                	mov    %eax,%edx
 9cb:	8b 45 f4             	mov    -0xc(%ebp),%eax
 9ce:	89 50 04             	mov    %edx,0x4(%eax)
        p += p->s.size;
 9d1:	8b 45 f4             	mov    -0xc(%ebp),%eax
 9d4:	8b 40 04             	mov    0x4(%eax),%eax
 9d7:	c1 e0 03             	shl    $0x3,%eax
 9da:	01 45 f4             	add    %eax,-0xc(%ebp)
        p->s.size = nunits;
 9dd:	8b 45 f4             	mov    -0xc(%ebp),%eax
 9e0:	8b 55 ec             	mov    -0x14(%ebp),%edx
 9e3:	89 50 04             	mov    %edx,0x4(%eax)
      }
      freep = prevp;
 9e6:	8b 45 f0             	mov    -0x10(%ebp),%eax
 9e9:	a3 c0 0d 00 00       	mov    %eax,0xdc0
      return (void*)(p + 1);
 9ee:	8b 45 f4             	mov    -0xc(%ebp),%eax
 9f1:	83 c0 08             	add    $0x8,%eax
 9f4:	eb 3b                	jmp    a31 <malloc+0xe1>
    }
    if(p == freep)
 9f6:	a1 c0 0d 00 00       	mov    0xdc0,%eax
 9fb:	39 45 f4             	cmp    %eax,-0xc(%ebp)
 9fe:	75 1e                	jne    a1e <malloc+0xce>
      if((p = morecore(nunits)) == 0)
 a00:	83 ec 0c             	sub    $0xc,%esp
 a03:	ff 75 ec             	push   -0x14(%ebp)
 a06:	e8 e5 fe ff ff       	call   8f0 <morecore>
 a0b:	83 c4 10             	add    $0x10,%esp
 a0e:	89 45 f4             	mov    %eax,-0xc(%ebp)
 a11:	83 7d f4 00          	cmpl   $0x0,-0xc(%ebp)
 a15:	75 07                	jne    a1e <malloc+0xce>
        return 0;
 a17:	b8 00 00 00 00       	mov    $0x0,%eax
 a1c:	eb 13                	jmp    a31 <malloc+0xe1>
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 a1e:	8b 45 f4             	mov    -0xc(%ebp),%eax
 a21:	89 45 f0             	mov    %eax,-0x10(%ebp)
 a24:	8b 45 f4             	mov    -0xc(%ebp),%eax
 a27:	8b 00                	mov    (%eax),%eax
 a29:	89 45 f4             	mov    %eax,-0xc(%ebp)
    if(p->s.size >= nunits){
 a2c:	e9 6d ff ff ff       	jmp    99e <malloc+0x4e>
  }
}
 a31:	c9                   	leave  
 a32:	c3                   	ret    
